package cn.ffcs.uec.staff.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import cn.ffcs.uec.staff.dao.UecPaymentDataDao;
import cn.ffcs.uec.staff.model.UecPaymentData;
import cn.ffcs.uom.common.constants.BaseUnitConstants;
import cn.ffcs.uom.common.dao.BaseDaoImpl;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.PageInfo;

@Repository("uecPaymentDataDao")
@Transactional
public class UecPaymentDataDaoImpl extends BaseDaoImpl implements UecPaymentDataDao {

	@Override
	public PageInfo queryPageInfoByUecPaymentData(UecPaymentData uecPaymentData, int current,
			int pageSize) {
		if (null != uecPaymentData) {
			StringBuilder sb = new StringBuilder(
					" ");
			sb.append(" select ja1.PAYMENT_DATA_ID paymentDataId,ja1.STAFF_ID staffId, ja1.MONTH_ID  monthId, ");
			sb.append(" DECODE(ja1.CACULATEFLAG,'N','否','是') caculateFlag,DECODE(ja1.CHECKFLAG,'N','否','是')  checkFlag, ");
			sb.append(" ja1.CPAYDATE cpaydate,ja1.CPERIOD  cperiod,ja1.CYEAR  cyear,ja1.CYEARPERIOD  cyearPeriod,ja1.DERATEPTG  derateptg, ");
			sb.append(" ja1.DR  dr,ja1.EXPENSE_DEDUCTION  expenseDeduction,ja1.F_1  f1,ja1.F_100  f100, ");
			sb.append(" ja1.F_101  f101,ja1.F_102  f102,ja1.F_103  f103,ja1.F_104  f104, ");
			sb.append(" ja1.F_105 f105,ja1.F_106 f106,ja1.F_107  f107,ja1.F_108 f108,ja1.F_116  f116, ");
			sb.append(" ja1.F_118  f118,ja1.F_119 f119,ja1.F_120  f120,ja1.F_121  f121, ");
			sb.append(" ja1.F_122  f122,ja1.F_123  f123,ja1.F_124  f124, ");
			sb.append(" ja1.F_125  f125,ja1.F_126 f126,ja1.F_127 f127,ja1.F_128  f128,ja1.F_129  f129, ");
			sb.append(" ja1.F_130  f130,ja1.F_131  f131,ja1.F_132 f132,ja1.F_133  f133,");
			sb.append(" ja1.F_134  f134,ja1.F_135 f135,ja1.F_136  f136,ja1.F_137  f137,");
			sb.append(" ja1.F_139  f139,ja1.F_143  f143,ja1.F_144  f144,ja1.F_145  f145,");
			sb.append(" ja1.F_146  f146,ja1.F_147  f147,ja1.F_148  f148,ja1.F_149  f149,ja1.F_15  f15,ja1.F_155  f155,ja1.F_156  f156,");
			sb.append(" ja1.F_157  f157,ja1.F_158  f158,ja1.F_159  f159,ja1.F_16  f16,");
			sb.append(" ja1.F_160  f160,ja1.F_161  f161,ja1.F_168  f168,");
			sb.append(" ja1.F_169  f169,ja1.F_171  f171,ja1.F_177  f177,ja1.F_178  f178,"
					+ "ja1.F_179  f179,ja1.F_18 f18,");
			sb.append(" ja1.F_180  f180,ja1.F_181  f181,ja1.F_182  f182,ja1.F_183  f183,");
			sb.append(" ja1.F_184  f184,ja1.F_186 f186,ja1.F_188  f188,");
			sb.append(" ja1.F_189  f189,ja1.F_19  f19,");
			sb.append(" ja1.F_2  f2,ja1.F_20 f20,ja1.F_23  f23,ja1.F_24 f24,ja1.F_28  f28,ja1.F_29  f29,");
			sb.append(" ja1.F_3  f3,ja1.F_31  f31,ja1.F_32  f32,");
			sb.append(" ja1.F_34  f34,ja1.F_35  f35,ja1.F_36  f36,ja1.F_37 f37,ja1.F_38  f38,ja1.F_39  f39,");
			sb.append(" ja1.F_4  f4,ja1.F_41  f41,ja1.F_42 f42,ja1.F_44  f44,");
			sb.append(" ja1.F_45  f45,ja1.F_46  f46,ja1.F_47  f47,ja1.F_49  f49,ja1.F_5  f5,ja1.F_50 f50,");
			sb.append(" ja1.F_51  f51,ja1.F_57  f57,ja1.F_59  f59,ja1.F_6 f6,");
			sb.append(" ja1.F_60  f60,ja1.F_61  f61,ja1.F_62  f62,ja1.F_63  f63,");
			sb.append(" ja1.F_64  f64,ja1.F_65  f65,ja1.F_66  f66,ja1.F_67  f67,");
			sb.append(" ja1.F_7  f7,ja1.F_71  f71,ja1.F_72 f72,ja1.F_73  f73,ja1.F_74  f74,");
			sb.append(" ja1.F_75  f75,ja1.F_76  f76,ja1.F_77  f77,ja1.F_78  f78,ja1.F_8  f8,ja1.F_82  f82,");
			sb.append(" ja1.F_89  f89,ja1.F_9 f9,");
			sb.append(" ja1.F_97 f97,ja1.F_99  f99,DECODE(ja1.ISDERATE,'N','否','是')  isderate,");
			sb.append(" ja1.NQUICKDEBUCT  nquickdebuct,DECODE(ja1.STOPFLAG,'N','否','是')  stopflag,");
			sb.append(" ja1.TAXABLE_INCOME taxableIncome,ja1.TAXRATE taxrate,ja1.TAXTABLEID taxtableid,"
					+ " ja1.TAXTYPE taxtableid,ja1.TS ts,ja1.VPAYCOMMENT vpaycomment,ja1.WORKDEPT workdept,ja1.WORKDEPTVID workdept,");
			sb.append(" ja1.WORKDEPTVID  workdeptvid,ja1.WORKORG  workorg,ja1.DSALSTARTDATE dsalstartdate,");
			sb.append(" ja1.F_210   f210,ja1.F_212   f212,ja1.F_213  f213,");
			sb.append(" ja1.F_214   f214,ja1.F_215 f215,ja1.F_216   f216,ja1.F_217 f217,ja1.F_218  f218,ja1.F_226  f226,");
			sb.append(" ja1.F_227  f227,ja1.F_228   f228,ja1.F_230  f230,ja1.F_232   f232,");
			sb.append(" ja1.PK_BANKDOC1   pkBankdoc1,ja1.PK_BANKACCBAS1  pkBankaccbas1,ja1.PK_BANKACCBAS2  pkBankaccbas2,");
			sb.append(" ja1.PK_BANKTYPE1  pkBanktype1,ja1.PK_BANKTYPE2  pkBanktype2,ja1.PK_LIABILITYDEPT  pkLiabilitydept,");
			sb.append(" ja1.PK_LIABILITYORG  pkLiabilityorg,ja1.PK_ORG  pkOrg,ja1.PK_PSNDOC pkPsndoc,ja1.PK_PSNJOB pkPsnjob,");
			sb.append(" ja1.PK_PSNORG pkPsnorg,ja1.PK_WA_CLASS pkWaClass ");
			sb.append(" from UEC_PAYMENT_DATA ja1 WHERE ja1.STATUS_CD = ? "); 
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);

			if (!StrUtil.isNullOrEmpty(uecPaymentData.getPkPsndoc())) {//判断数据是否是集团的
				sb.append(" AND ja1.PK_PSNDOC = ? ");
				params.add(uecPaymentData.getPkPsndoc());
			} else if (!StrUtil.isNullOrEmpty(uecPaymentData.getStaffId())) {
				sb.append(" AND ja1.STAFF_ID = ? ");
				params.add(uecPaymentData.getStaffId());
			}
			return this.jdbcFindPageInfo(sb.toString(), params, current,
					pageSize, UecPaymentData.class);
		}
		return null;
	}

}
